---
layout: example
categories: example/v1.0.0
version: v1.0.0
title: Centering markers
description: When a user selects a marker, center the map on its coordinates.
tags:
  - markers
  - animation
---
<div id='map'></div>
<script>
    var map = L.mapbox.map('map')
      .setView([37.77396, -122.4366], 13)
      .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));

    var myFeatureLayer = L.mapbox.featureLayer('/mapbox.js/assets/data/sf_locations.geojson')
      .addTo(map);

    myFeatureLayer.on('click', function(e) {
        map.panTo(e.layer.getLatLng());
    });
</script>
